/**
 * Created by Francis.LW on 2017/10/20.
 *
 * 表单组件服务接口
 */
import {postRequest, getRequest} from '@/common/request'
import {urls} from './url'

const controlApi = urls.control

function listAllControl(param, success, complete) {
  postRequest(controlApi.listAllControl, {}, param, success, complete)
}

function listControl(param, page, pageSize, success, complete) {
  postRequest(controlApi.listControl + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function addControl(param, success, complete) {
  postRequest(controlApi.addControl, {}, param, success, complete)
}

function updateControl(id, param, success, complete) {
  postRequest(controlApi.updateControl + id, {}, param, success, complete)
}

function getControl(id, success, complete) {
  getRequest(controlApi.getControl + id, {}, success, complete)
}

function removeControl(ids, success, complete) {
  postRequest(controlApi.removeControl, {}, ids, success, complete)
}

function deleteSingleControl(id, success, complete) {
  let ids = []
  ids.push(id)
  removeControl(ids, success, complete)
}

export default {
  listAllControl,
  listControl,
  addControl,
  updateControl,
  getControl,
  removeControl,
  deleteSingleControl
}
